/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package motiveai.tests;

import motiveai.annotation.DurationOfBehaviour;
import motiveai.components.BehaviourEntity;
import motiveai.factors.Environment;

/**
 *
 * @author oxplay
 */
public class Test4MoveToEnemy extends BehaviourEntity<Test4Agent> {
    
    public Test4MoveToEnemy() {
    }

    public boolean canBeUsed(Test4Agent agent, Environment environment) {
        if (environment.getIntegerFactor("closeEnemyType") > 0 && !environment.getBooleanFactor("inAttackRange")) {
            return true;
        }
        return false;
    }

    @Override
    @DurationOfBehaviour(duration = 0.3f)
    public float behave(Test4Agent agent, Environment environment) {
        agent.getSpatial().getControl(MoveControl.class).moveTo(agent.closeEnemy.getSpatial().getLocalTranslation());
        return 10;
    }
}
